<template>
	<view class="refund">
		<view class="content">
			<view class="line">
				<text>快递公司</text>
				<picker class="text" @change="bindPickerChange" :value="index" :range="array">
					<text v-if="refund_shipping_company">{{refund_shipping_company}}</text>
					<text class="txt" v-else>请选择快递公司</text>
				</picker>
			</view>
			<view class="line">
				<text>快递单号</text>
				<input type="text" v-model="refund_shipping_code" placeholder-style="color:rgba(66,81,114,0.2)" placeholder="请输入快递单号" value="" />
			</view>
		</view>
		<view class="bottom" @click="subForm()">确认提交</view>
	</view>
</template>

<script>
	import serve from '../../static/request.js';
	import storage from '../../static/appkey.js';
	import common from '../../static/jump.js';
	export default {
		data() {
			return {
				id: 0,
				refund_shipping_company:"",
				refund_shipping_code : "",
				array: ['顺丰', '韵达', '圆通', '申通', '中通', 'EMS', '天天', '邮政', '其他'],
			}
		},
		methods: {
			bindPickerChange: function(e) {
				console.log('picker发送选择改变，携带值为', e.target.value)
				this.refund_shipping_company = this.array[e.target.value]
			},
			subForm() {
				var self = this;
				if (self.refund_shipping_company == '') {
					uni.showToast({
						title: '请选择快递公司',
						icon: 'none'
					});
					return;
				}
				if (self.refund_shipping_code == '') {
					uni.showToast({
						title: '请填写快递单号',
						icon: 'none'
					});
					return;
				}
				serve.request({
					url: '/member/order-customer/refund-sales-return',
					data:{
						id:self.id,
						refund_shipping_code: self.refund_shipping_code,
						refund_shipping_company : self.refund_shipping_company
					}
				}).then(res => {
					uni.showToast({
						title:res.message,
						icon: 'none',
						success() {
							setTimeout(function () {
								uni.redirectTo({
									url:'/pages/my/saleDatails?id=' + self.id
								});
							}, 2000) 
						}
					});
				});
			},
			jump(jump_type, jump_link){
				common.jump(jump_type, jump_link);
			}
		},
		onLoad(options) {
			this.id=options.id || 0;
			if(this.id == 0) {
				uni.showToast({
					title: "错误的访问方式",
					icon: 'none',
					success() {
						setTimeout(function () {
							this.jump('refund_list')
						}, 2000) 
					}
				});
			}
		},
		onPullDownRefresh() {
			console.log('refresh');
			setTimeout(function() {
				uni.stopPullDownRefresh(); //结束下拉加载状态
			}, 1000);
		}
	}
</script>

<style scoped lang="scss">
	.refund {
		.content {
			padding: 0upx 0upx 0upx 38upx;

			.line {
				display: flex;
				justify-content: space-between;
				padding-top: 75upx;
				font-size: 32upx;

				.text {
					width: 552upx;
					height: 100%;
					border-bottom: 1upx rgba(66, 81, 114, 0.05) solid;
					padding-bottom: 20upx;
					
					.txt{
						color: rgba(66, 81, 114, 0.2)
					}
				}

				input {
					padding-bottom: 20upx;
					width: 552upx;
					border-bottom: 1upx rgba(66, 81, 114, 0.05) solid;
				}
			}
		}

		.bottom {
			width: 100%;
			height: 100upx;
			line-height: 100upx;
			text-align: center;
			font-size: 32upx;
			color: rgba(255, 255, 255, 1);
			background: rgba(251, 202, 63, 1);
			bottom: 0upx;
			position: fixed;
		}
	}
</style>
